package com.biglead.demo.controller;

import com.biglead.demo.common.R;
import com.biglead.demo.service.OrderService;
import com.biglead.demo.service.SecKillService;
import com.biglead.demo.vo.OrderVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 订单 前端控制器
 * </p>
 *
 * @author 早起的年轻人
 * @since 2023-03-14
 */
@Api(tags="订单模块")
@RestController()
@RequestMapping("/orders")
@Slf4j
public class OrderController {
    @Autowired
    private OrderService orderService;

    /**
     * 下单
     * @param goodsId 商品ID
     * @param userId
     * @return
     */
    @GetMapping("/create/{id}")
    public R createOrder(@PathVariable("id") Long goodsId,@RequestHeader Long userId) {
        return orderService.createPreOrder(goodsId,userId);
    }

    /**
     * 查询订单详情
     * @param orderId
     * @return
     */
    @GetMapping("/detail/{id}")
    public R detail(@PathVariable("id") Long orderId) {
        OrderVo orderVo = orderService.detail(orderId);
        return R.okData(orderVo);
    }

}
